﻿using System;
using System.Collections.Generic;
using BGM.Domain.DTO;



namespace BGM.Sensors.MeasuringDevice
{
    public class SimulatorDevice : IMeasuringDevice
    {
        #region IGlucoseMessuringDevice Members

        public List<Reading> GetData()
        {
            return GenerateTestData();
        }
        private List<Reading> GenerateTestData()
        {
            List<Reading> list = new List<Reading>();
            DateTime time = DateTime.Now;
            Random rand = new Random();
            for (int i = 0; i < 30; i++)
            {
                time = time.AddHours(i);
                list.Add(new Reading(time, rand.Next(4, 9) * 18));
            }
            for (int i = 0; i < 10; i++)
            {
                time = time.AddHours(i);
                list.Add(new Reading(time, rand.Next(2, 20) * 18));
            }
            return list;
        }



        public event EventHandler Progress;

        #endregion

        #region IPlugin Members

        public string Name
        {
            get { return "Data simulator"; }
        }

        public string Description
        {
            get { return "Generates sample measurements"; }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {

        }

        #endregion

        #region IGlucoseMeasuringDevice Members

        public List<Reading> GetReadings(object portName)
        {
            return GenerateTestData();
        }

        public event MessageRecievedEventhandler MessageRecieved;

        #endregion
    }
}
